<?php
include '../include/functions.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//Dtd html 4.01 Transitional//EN"
"http://www.w3.org/tr/html4/loose.dtd">
<html>
  <head>
    <title>JoshHughes.com NHL Hockey Pool</title>
	<link rel="shortcut icon" href="http://hockey.joshhughes.com/NHL/images/nhlFavicon.gif" />
	<link rel="stylesheet" href="http://hockey.joshhughes.com/css/NHL.css" type="text/css">
    <script src="http://hockey.joshhughes.com/scripts/prototype.js" type="text/javascript"></script>
	<script src="http://hockey.joshhughes.com/scripts/scriptaculous.js" type="text/javascript"></script>
	<script src="http://hockey.joshhughes.com/scripts/hockey.js" type="text/javascript"></script>
  </head>
<body>
<div id="pagewidth" >
	<div id="header" >	
		<?PHP include_once("layout/header.html"); ?>
	</div>
	
	<div id="wrapper" class="clearfix" > 
		<div id="maincol" >
		<!-- InstanceBeginEditable name="Contents" -->		
				<table width="510" cellpadding="5" cellspacing="0">
					<tr>
					<td class="redbg">
				<?php
				//Connect To Database
				dbConnect();
				
				//check to see if a Weeknum value was passed, if not, set WeekNum to CurrWeek.
				if (($Weeknum == NULL) || ($Weeknum == "")) {
					$Weeknum = getWeek("NHL");
				}
				
				//check to make sure $Weeknum > 1 AND $Weeknum < 21
				$Weeknum = checkWeekBounds($Weeknum);
				
				//Write SQL Query to extract specified data
				$SQL = "SELECT * FROM NHLSchedule Where WEEK=".$Weeknum." ORDER BY GameDate, GameTime";
				//Open Record Set using SQL Query
				$result = mysql_query($SQL) or die("Cannot query the database.<br/>");
				?>
				<form action="<? echo $PHP_SELF; ?>" method="POST" name="WeekForm">
				<table bgcolor="#FFFFFF" width="500" align="center"><tr>
				<tr><td colspan="7" align="center"><H1><?	getWeekBanner($Weeknum)	?></H1></td>
				<td align="right"><a href="<? echo $PHP_SELF; ?>?Weeknum=<? echo $Weeknum-1; ?>" class="permLink">Prev</a> | <a href="<? echo $PHP_SELF; ?>?Weeknum=<? echo $Weeknum+1; ?>" class="permLink">Next</a> &nbsp; or &nbsp; 
					<B>Go to:</B>
					<?
						WeekDropDown($Weeknum)
					?>
				</td>
				</tr>
				</table>
				</form>
				<table bgcolor=#FFFFFF callpadding="5" cellspacing="0" width="500" align="center">
				  <tr>
					<TH align="left">Date</TH>
					<Td colspan="7" align="center"><?= date("l F jS, Y g:i A", time() + (3600 * 3)); ?> EST</td>
				  </tr>
				<tr><TH colspan="2">Visitors</TH><TH>&nbsp;&nbsp;&nbsp;</TH><TH colspan="2">Home</TH><TH align="left" width="100">Game Time</TH><TH colspan="2" align="Center">Winner</TH></tr>
				<?
				$CurrentDate = 20031022;
				$row = -1;
				do{
				if (($myrow["Away"] != NULL) && ($myrow["Away"] != "")) {
				//increment i for the row color
				$row++;
					 echo "<tr bgcolor=\"".getRowColor($row)."\">";
					 if ($myrow["GameDate"] == $CurrentDate) {
						//do nothing
					 } 
					 else {
						$CurrentDate = $myrow["GameDate"];
						echo "<td colspan=\"8\"><B><U>".date('l F jS, Y',strtotime($myrow["GameDate"]))."</U></B></td></tr>";
						$row++;
						echo "<tr bgcolor=\"".getRowColor($row)."\">";
					 }//end if ($myrow["GameDate"] != $CurrentDate)
					 echo "<td width=\"5\"><img src=\"http://hockey.joshhughes.com/NHL/images/small/".$myrow["Away"].".gif\"></td><td width=\"5\">".$myrow["Away"]."</td><td width=\"1\"> @ </td>";
					 echo "<td width=\"5\">".$myrow["Home"]."</td><td width=\"5\"><img src=\"http://hockey.joshhughes.com/NHL/images/small/".$myrow["Home"].".gif\"></td>";
					 echo "<td>".date('g:i A',strtotime($myrow["GameTime"]))." EST</td>";
					 if ($myrow["Winner"] != "-") {
						echo "<td width=\"5\"><img src=\"http://hockey.joshhughes.com/NHL/images/small/".$myrow["Winner"].".gif\"></td><td width=\"5\"><B>".$myrow["Winner"]."</B></td></tr>";
					 } else {
					echo "<td width=\"5\">&nbsp;</td><td><B>&nbsp;</B></td></tr>";
					 }//end if ($myrow["Winner"] != "")
				}//end if (($myrow["Away"] != NULL) && ($myrow["Away"] != ""))
				}while($myrow = mysql_fetch_array($result));
					 echo "<tr><td colspan=\"8\" align=\"center\"><H4>You must be registered member of this pool site, and you must be logged in to submit picks.</H4>";
					 echo "<p>If you are a registered member here to make your picks, please login in the left hand &quot;Log On&quot; box.</p>";
					 echo "<p>If you are logged you may need up update your profile to include the NHL as a pool you want to play in.  <a href=\"http://hockey.joshhughes.com/editprofile.php\" class=\"permLink\">Edit your profile here</a>.</p>";
					 echo "<p>If you wish to register to make picks in the pool, <a href=\"http://hockey.joshhughes.com/register.php\" class=\"permLink\">click here</a> or the &quot;Register&quot; link at the top of the page.";
					 echo "</td></tr></table></form>";
				?>
				</td></tr></table>
		
		<!-- InstanceEndEditable -->
		
		</div> <!-- Close maincol div   -->
		
		<div id="leftcol" >		
			<?PHP include_once("layout/left_column.php"); ?>		
		</div>
		
			
	</div> <!-- Close wrapper div   -->

	<div id="footer" >	
		<?PHP include_once("layout/footer.html"); ?>	
	</div>

		
</div>
</body>
</html>